home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #12 / Amiga Plus CD - 2002 - No. 12.iso / Tools / Freeware / PerfectPaint / rexx / general / InsertPicture.rx < prev    next >
Encoding:
Text File  |  2001-11-02  |  1.4 KB  |  115 lines

  1. /*     arexx Script 'Insert Picture' */
  2.  
  3.     options results
  4.     parse ARG Port mode b
  5.     
  6.     ADDRESS value Port
  7.  
  8.     pp_GetCurrentBrush; B0=result    
  9.     pp_FindEmptyBrush; Brush=result
  10.     IF Brush=-1 THEN DO; pp_Warn "Can't*find*empty|Brush."; EXIT; END
  11.     pp_SetBrush Brush
  12.  
  13.     file2="ram:multifile"
  14.     IF OPEN('g',file2, 'R') then DO
  15.         file = READLN('g')
  16.         call close('g')
  17.     END
  18.     ELSE
  19.     DO
  20.         EXIT
  21.     END
  22.  
  23.     ADDRESS COMMAND 'delete >nil: ram:multifile'
  24.             file2=""
  25.             do i=1 to LENGTH(file)
  26.                 a=SUBSTR(file,i,1)
  27.                 if a=" " then DO
  28.                     a="*"
  29.                 END
  30.                 file2=file2||a
  31.             END
  32.             file=file2
  33.  
  34.  
  35.     pp_BLoad File
  36.         
  37.     pp_GetWidthB; W=result
  38.     pp_GetHeightB; H=result
  39.     pp_GetWidth; Width=result
  40.     pp_GetHeight; Height=result
  41.  
  42.     X2=W/2
  43.     Y2=H/2    
  44.     X=Width/2
  45.     Y=Height/2
  46.     X3=X-X2
  47.     Y3=Y-Y2
  48.  
  49.             IF Mode=0 then DO
  50.                 posx=X2;posy=Y2
  51.             END
  52.  
  53.             IF Mode=10 then DO
  54.                 posx=X;posy=Y2
  55.             END
  56.  
  57.             IF Mode=20 then DO
  58.                 posx=X+X3;posy=Y2
  59.             END
  60.  
  61.             IF Mode=3 then DO
  62.                 posx=X2;posy=Y
  63.             END
  64.  
  65.             IF Mode=13 then DO
  66.                 posx=X;posy=Y
  67.             END
  68.  
  69.             IF Mode=23 then DO
  70.                 posx=X+X3;posy=Y
  71.             END
  72.  
  73.             IF Mode=6 then DO
  74.                 posx=X2;posy=Y+Y3
  75.             END
  76.  
  77.             IF Mode=16 then DO
  78.                 posx=X;posy=Y+Y3
  79.             END
  80.  
  81.             IF Mode=26 then DO
  82.                 posx=X+X3;posy=Y+Y3
  83.             END
  84.  
  85.     Ux=posx-W/2-1
  86.     Uy=posy-H/2-1
  87.  
  88.     Ux1=Ux+W+2
  89.     Uy1=Uy+H+2
  90.  
  91.     if Ux<0 then Ux=0
  92.     if Uy<0 then Uy=0
  93.     if Ux1>Width-1 then Ux1=Width-1
  94.     if Uy1>Height-1 then Uy1=Height-1
  95.  
  96.     pp_UpdateUndoBox Ux Uy Ux1 Uy1
  97.  
  98.     pp_EffectOff
  99.     pp_Plot posx posy
  100.     
  101.     pp_FreeBrush
  102.     pp_SetBrush B0
  103.  
  104.     EXIT
  105.  
  106.  
  107.  
  108.  
  109.  
  110.     
  111.  
  112.  
  113.     
  114.  
  115.